package library;

import library.ListBook;
import library.user.Admin;
import library.user.NormalUser;
import library.user.User;

import java.util.Scanner;

public class Main {
    //用户登录，身份验证
    public static User Login(){
        System.out.print("请输入你的用户名：");
        Scanner scanner = new Scanner(System.in);
        String name  = scanner.next();
        User user = null;
        while(true){
            System.out.println("请选择你的用户类型（1.普通用户，2.管理员）");
            System.out.print("请输入你的用户类型序号：");
            int choice = scanner.nextInt();
            if(choice == 1){
                user =  new NormalUser(name);
                break;
            }else if (choice == 2){
                user = new Admin(name);
                break;
            }else {
                System.out.println("选择错误！");
            }
        }
        return user;
    }
    public static void main(String[] args) {
        ListBook listBook = new ListBook();
        //用户登录，身份验证
        User user = Login();

        while(true){
            //打印菜单选项
            int choice = user.menu();
            //图书操作
            user.work(choice, listBook);
        }
    }
}
